package com.leyou.order.controller;

import com.leyou.order.service.CollectService;
import com.leyou.order.utils.Collect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 收藏模块  实战
 * */
@RestController
public class CollectController {
    @Autowired
    private CollectService collectService;

    /**
     * 关注，保存到收藏夹中
     * */
    @PostMapping("/order/collect/save")
    public ResponseEntity<Boolean> save(@RequestBody Collect collect){
        Boolean flag = collectService.save(collect);
            return ResponseEntity.ok(flag);
    }

    /**
     * 查询我的收藏
     * */
    @GetMapping("/order/collect/find")
    public ResponseEntity<List<Collect>> findCollect(){
        List<Collect> collects = collectService.findCollect();
        return ResponseEntity.ok(collects);
    }

    /**
     * 降价通知
     * */
    @PostMapping("/order/collect/notice")
    public ResponseEntity<String> updateNotice(@RequestBody Collect collect){
        String s = collectService.updateNotice(collect);
        return ResponseEntity.ok(s);
    }

}
